package com.bsb.biz.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.bsb.base.mapper.BsbApplyExpertMapper;
import com.bsb.base.mapper.BsbUserMapper;
import com.bsb.base.model.BsbApplyExpert;
import com.bsb.base.model.BsbApplyExpertExample;
import com.bsb.base.model.BsbUser;

@Service
public class BsbApplyExpertService{
	
	@Resource
	private BsbApplyExpertMapper bsbApplyExpertMapper;
	@Resource
	private BsbUserMapper bsbUserMapper;
	
	public void addBsbApplyExpert(BsbApplyExpert bsbApplyExpert) {
		bsbApplyExpertMapper.insertSelective(bsbApplyExpert);
	}
	
	public void delBsbApplyExpertByUuid(String uuid) {
		bsbApplyExpertMapper.deleteByPrimaryKey(uuid);
	}
	
	public void updateBsbApplyExpert(BsbApplyExpert bsbApplyExpert) {
		bsbApplyExpertMapper.updateByPrimaryKeySelective(bsbApplyExpert);
	}
	
	public void updateBsbApplyExpertByExample(BsbApplyExpert bsbApplyExpert,BsbApplyExpertExample bsbApplyExpertExample){
	    bsbApplyExpertMapper.updateByExampleSelective(bsbApplyExpert,bsbApplyExpertExample);
	}
	
	public BsbApplyExpert getBsbApplyExpertByUuid(String uuid) {
		return bsbApplyExpertMapper.selectByPrimaryKey(uuid);
	}
	
	public List<BsbApplyExpert> getPageBsbApplyExpert(BsbApplyExpertExample bsbApplyExpertExample) {
		return bsbApplyExpertMapper.selectPage(bsbApplyExpertExample);
	}
	
	public int countBsbApplyExpert(BsbApplyExpertExample bsbApplyExpertExample) {
		return bsbApplyExpertMapper.countByExample(bsbApplyExpertExample);
	}
	
	public List<BsbApplyExpert> selectByExample(BsbApplyExpertExample example){
	    return bsbApplyExpertMapper.selectByExample(example);
	}

	public void updatePass(BsbApplyExpert apply) {
		bsbApplyExpertMapper.updateByPrimaryKeySelective(apply);
		String uuid = apply.getUuid();
		BsbApplyExpert selectByPrimaryKey = bsbApplyExpertMapper.selectByPrimaryKey(uuid);
		String userId = selectByPrimaryKey.getUserId();
		String duty = selectByPrimaryKey.getDuty();
		String skill = selectByPrimaryKey.getSkill();
		String profile = selectByPrimaryKey.getProfile();
		BsbUser user = new BsbUser();
		user.setUuid(userId);
		user.setDuty(duty);
		user.setSkill(skill);
		user.setProfile(profile);
		user.setRole("4");
		bsbUserMapper.updateByPrimaryKeySelective(user);
	}
}
